package net;

/**
 * Information about a running GameServer.
 */
public class GameInfo
{
	public final String module;
	public final int port, numPlayers;
	public final java.net.InetAddress host;
	public final java.util.Map<String, String> options;

	/**
	 * Creates a GameInfo instance with the specified properties.
	 * @param host the hostname of the GameServer playing the game
	 * @param port the port on which the GameServer communicates
	 * @param module the path to the module that specifies the game being played
	 * @param numPlayers the requisite number of players
	 * @param options the client-side options
	 */
	public GameInfo(java.net.InetAddress host, int port, String module, int numPlayers, java.util.Map<String, String> options) {
		this.host = host;
		this.port = port;
		this.module = module;
		this.numPlayers = numPlayers;
		this.options = java.util.Collections.unmodifiableMap(new java.util.HashMap<String, String>(options));
	}
	public String displayInfo() {
		String ans= "<html>Play " + module + "<br> &nbsp; ==> ";
		if (numPlayers==1) ans+= "1 player";
		else ans+= (numPlayers + " players");
		for (String o:options.keySet()) {
			ans+= ("<br> &nbsp; ==> "+o+"="+options.get(o));	
		}
		return ans;
	}
	public String toString() {
		return "<html>Game Info:<br> &nbsp; host="+host+"<br> &nbsp; port="+port+"<br> &nbsp; module="+module+"<br> &nbsp; numPlayers="+numPlayers+"<br> &nbsp; options="+options+"</html>";
	}
}
